import numpy as np
# 创建向量
arr1 = np.arange(1,10)
# 变形为矩阵
# arr2 = arr1.reshape(3,3)
# arr2 = arr1.reshape(3,-1)
arr2 = arr1.reshape(-1,3)
print(arr2)
"""
[[1 2 3]
 [4 5 6]
 [7 8 9]]
"""

# 创建矩阵
arr1 = np.array([[1,2,3],[4,5,6]])
print(arr1)
"""
[[1 2 3]
 [4 5 6]]
"""
# 变形为向量
# arr2 = arr1.reshape(6)
arr2 = arr1.reshape(-1)
print(arr2) # [1 2 3 4 5 6]
# 变形为矩阵
# arr3 = arr1.reshape(1,6)
arr3 = arr1.reshape(1, -1)
print(arr3) # [[1 2 3 4 5 6]]